package study.singleton;
//以当前线程为key 创建 value = new ThreadPoolSingleton 的map
//确保了单个线程内 Singleton 的唯一性
public class ThreadPoolSingleton {

    private ThreadLocal<ThreadPoolSingleton> threadPoolSingleton = new ThreadLocal<ThreadPoolSingleton>(){
        @Override
        protected ThreadPoolSingleton initialValue() {
            return new ThreadPoolSingleton();
        }
    };

    private ThreadPoolSingleton (){}

    public ThreadPoolSingleton getInstance(){
        return threadPoolSingleton.get();
    }
}
